function remoteRequestForError(form, prefix, url) {
    //if (!collectIDs("include_", form))
    //    return false;
    var query = Array();
    var contents = formContents(form);
    for (var j = 0; j < contents[0].length; j++)
        if (contents[0][j].indexOf(prefix) == 0) {
            query[contents[0][j]] = contents[1][j];
    }
    var parameters = queryString(query);
    var http_request = false;
    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
    }
    else { // IE
        alert('Cannot create XMLHTTP instance');
        return false;
    }
    if (!http_request) {
        alert('Cannot create XMLHTTP instance');
        return false;
    }

    var insertContents = function() {
        if (http_request.readyState == 4) {
            if (http_request.status != 200) {//failure
                alert('There was a problem with the request. Status(' + http_request.status + ')');
                //         OnAndOffDisabled(form,false);
            }
            //complete
            jsonString = http_request.responseText;
            var jsObject;
            try {
                jsObject = JSON.parse(jsonString);
                if (jsObject.result_ok) {
                    alert("OK");
                    // history.back();
                }
                else {
                    addError(jsObject);
                    //              OnAndOffDisabled(form,false);
                }
            }
            catch (e) {
                alert("catch " + e.Message);
                // alert('There was a problem with the request. Status('+http_request.status+')');
                //            OnAndOffDisabled(form,false);
            }
        }
    }

    //  OnAndOffDisabled(form,true);
    http_request.onreadystatechange = insertContents;
    http_request.overrideMimeType('application/jsonrequest');
    http_request.open('POST', url, true);
    http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http_request.setRequestHeader("Content-length", parameters.length);
    http_request.setRequestHeader("Connection", "close");
    http_request.send(parameters);
    return false;
}

function OnAndOffDisabled(form, disabled) {
    var elems = document.getElementsByTagName("input");
    for (var i = 0; i < elems.length; i++)
        elems[i].disabled = disabled;
}

function addError(jsObject) {
    for (k in jsObject) {
        var elem = document.getElementsByName(k);
        for (var i = 0; i < elem.length; i++) {
            if (jsObject[k] != '') {
                elem[i].style.color = 'red';
                elem[i].value = jsObject[k];
            }
            else {
                elem[i].style.color = 'green';
                elem[i].value = 'OK';
            }
        }
    }
}

